// window.onload=function(){
    // console.log("aaa")
    var userName=document.getElementById("userName")
    var userPassword=document.getElementById("userPassword")
    var email=document.getElementById("email")
    var code=document.getElementById("code")

    var send=document.getElementById("send")
       
        send.onclick=function(){
            var Email=email.value;
            $.ajax({

                type:"post",
                url:"http://118.195.129.130:3000/user/getMailCode",
                async:true,
                data:{
                    mail:Email
                },
                success:function(data){
                    console.log(data)
                },
                error:function(err){
                    console.log("错误")
                }
            })
        }
    
    var register=document.getElementById("register")
    register.onclick=function(){
        var userNAME=userName.value;
        var userPASS=userPassword.value;
        var Code=code.value;
        var Email=email.value;

        $.ajax({
            type:"post",
            url:"http://118.195.129.130:3000/user/reg",
            async:true,
            data:{
                us:userNAME,
                ps:userPASS,
                mile:Email,
                code:Code
            },
            success:function(data) {
                console.log(data);
                if(data.err=-1){
                   window.location.href="../index.html";
                }
                if(data.err=0){
                     alert("验证码或密码错误");
                }
            },
            error:function(err){
                console.log("错误");
            }
        });
        
            
        
    }
// }